package com.icez.base_compose_framework

import android.annotation.SuppressLint
import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.icez.base_compose_framework.util.BNetworkUtil

/**
 * 状态类
 * @author icez
 */
@SuppressLint("RememberReturnType")
@Composable
fun BRememberAppState(navHostController: NavHostController = rememberNavController(),context: Context = LocalContext.current) = remember(navHostController,context){
        BaseAppState(navHostController,context)
    }

class BaseAppState(val navHostController: NavHostController,private val context: Context){
    // 是否在线
    var isOnline by mutableStateOf(true)

    /**
     * 刷新网络状态
     */
    fun refreshOnline(){
        isOnline = BNetworkUtil.isNetworkAvailable(context)
    }
}